<form id="edit-form" class="form-horizontal form-ajax" role="form" data-toggle="validator" method="POST" action="">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Group')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:build_select('group[]', $groupdata, $groupids, ['class'=>'form-control selectpicker', 'data-rule'=>'required'])}
        </div>
    </div>
    <div class="form-group">
        <label for="username" class="control-label col-xs-12 col-sm-2">{:__('Username')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="text" class="form-control" id="username" name="row[username]" value="{$row.username|htmlentities}" data-rule="required;username" />
        </div>
    </div>
    <div class="form-group">
    <label for="email" class="control-label col-xs-12 col-sm-2">{:__('Email')}:</label>
    <div class="col-xs-12 col-sm-8">
    <input type="email" class="form-control" id="email" name="row[email]" value="{$row.email|htmlentities}" data-rule="required;email" />
    </div>
    </div>
    <div class="form-group">
        <label for="nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="text" class="form-control" id="nickname" name="row[nickname]" autocomplete="off" value="{$row.nickname|htmlentities}" data-rule="required" />
        </div>
    </div>
    <div class="form-group">
        <label for="password" class="control-label col-xs-12 col-sm-2">{:__('Password')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="password" class="form-control" id="password" name="row[password]" autocomplete="new-password" value="" data-rule="password" />
        </div>
    </div>
    <div class="form-group">
        <label  class="control-label col-xs-12 col-sm-2">{:__('手机号')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="text" class="form-control" id="phone" name="row[phone]"  value="{$row.phone|htmlentities}"  />
        </div>
    </div>
    <div class="form-group address" style="display: none">
        <label class="control-label col-xs-12 col-sm-2">{:__('所属区域')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-city" data-rule="required" data-toggle="city-picker" class="form-control" name="row[city]" type="text" value="{$row.city|htmlentities}">
            <!--<div class='control-relative'><input id="c-city" class="form-control" data-toggle="city-picker" name="row[city]" type="text">{$row.city|htmlentities}</div>-->
        </div>
    </div>
    <div class="form-group hospital" style="display: none">
        <label  class="control-label col-xs-12 col-sm-2">{:__('所属医院')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-hospital"  data-source="aa/hospital/index?address={$row.city|htmlentities}" class="form-control selectpage" name="row[hospital]" type="text" value="{$row.hospital|htmlentities}">
        </div>
    </div>
    <div class="form-group sort" style="display: none">
        <label  class="control-label col-xs-12 col-sm-2">{:__('所属科室')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-section"  data-source="aa/section/index?id={$row.hospital|htmlentities}" class="form-control selectpage" name="row[section]" type="text" value="{$row.section|htmlentities}">
        </div>
    </div>
    <!--<div class="form-group">-->
        <!--<label for="loginfailure" class="control-label col-xs-12 col-sm-2">{:__('Loginfailure')}:</label>-->
        <!--<div class="col-xs-12 col-sm-8">-->
            <!--<input type="number" class="form-control" id="loginfailure" name="row[loginfailure]" value="{$row.loginfailure}" data-rule="required" />-->
        <!--</div>-->
    <!--</div>-->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], $row['status'])}
        </div>
    </div>
    <div class="form-group hidden layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
<script src="/assets/js/jquery-1.8.3.min.js"></script>
<script>
    $('.selectpicker').change(function () {
        var arr = $(this).val();
        console.log(arr.indexOf('2'))
        if(arr.indexOf('2') >= 0){
            $('.address').css("display","block");
        }else if(arr.indexOf('6') >= 0){
            $('.address').css("display","block");
            $('.hospital').css("display","block");
        }else if(arr.indexOf('7') >= 0){
            $('.address').css("display","block");
            $('.hospital').css("display","block");
            $('.sort').css("display","block");
        }else{
            $('.address').css("display","none");
            $('.hospital').css("display","none");
            $('.sort').css("display","none");
        }
    })
    $(function () {
        var obj = $('.selectpicker option:selected').val();
        console.log(obj);
        if(obj == 2){
            $('.address').css("display","block");
        }else if(obj == 6){
            $('.address').css("display","block");
            $('.hospital').css("display","block");
        }else if(obj == 7){
            $('.address').css("display","block");
            $('.hospital').css("display","block");
            $('.sort').css("display","block");
        }else{
            $('.address').css("display","none");
            $('.hospital').css("display","none");
            $('.sort').css("display","none");
        }
    })
    $('#c-section').focus(function () {

        var arr = $('#edit-form').serializeArray()
        var id = arr[8]['value']
        $.ajax({
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/admin/index/secci" ,//url
            data: {id:id},
            success: function (data) {

            },
            error : function() {

            }
        })
    })

    $('#c-hospital').focus(function () {
        var arr = $('#edit-form').serializeArray()
        console.log(arr)
        var id = arr[6]['value']
        $.ajax({
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/admin/index/secc" ,//url
            data: {id:id},
            success: function (data) {

            },
            error : function() {

            }
        })


    })
</script>